package com.lry.crawlers.listener;

import com.lry.crawlers.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class SurviveListener {
    public static final String uuid = UUID.randomUUID().toString();
    //注入RabbitTemplate
    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Scheduled(cron = "0/10 * * * * ?")
    public void survice(){
        rabbitTemplate.convertAndSend(RabbitMQConfig.SURVIVEEXCHANGE_NAME,"survice",uuid);
    }
}
